package satir.cell.factory;

import org.json.JSONException;
import org.json.JSONObject;

import satir.card.Deck;
import satir.cell.Cell;

/**
 * A factory for creating Cell objects.
 * 
 * @version 2.0 March 2012
 * @author Chris Chan
 */
public class CellFactory {
	
	/** The width. */
	protected int width;
	
	/** The height. */
	protected int height;
	
	/** The border horizontal. */
	protected char borderHorizontal;
	
	/** The border vertical. */
	protected char borderVertical;
	
	/** The deck. */
	protected Deck deck;
	
	/**
	 * Creates a new Cell object.
	 *
	 * @return the cell
	 */
	public Cell createCell(){
		return new Cell(width, height, borderHorizontal, borderVertical, "");
	}	
	/**
	 * Sets the cell detail from cell JSON.
	 *
	 * @param cellJson the new cell detail
	 */
public void setCellDetail(JSONObject cellJson){
		try {
			this.width = cellJson.getInt("width");
			this.height = cellJson.getInt("width");;
			this.borderHorizontal = cellJson.getString("borderHorizontal").charAt(0);
			this.borderVertical = cellJson.getString("borderVertical").charAt(0);
		} catch (JSONException e) {
			e.printStackTrace();
		}		
	}
}